package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsInboundType;
import com.scau402.system.service.IWmsInboundTypeService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 入库类型Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/inboundType")
public class WmsInboundTypeController extends BaseController
{
    @Autowired
    private IWmsInboundTypeService wmsInboundTypeService;

    /**
     * 查询入库类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:inboundType:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsInboundType wmsInboundType)
    {
        startPage();
        List<WmsInboundType> list = wmsInboundTypeService.selectWmsInboundTypeList(wmsInboundType);
        return getDataTable(list);
    }

    /**
     * 导出入库类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:inboundType:export')")
    @Log(title = "入库类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsInboundType wmsInboundType)
    {
        List<WmsInboundType> list = wmsInboundTypeService.selectWmsInboundTypeList(wmsInboundType);
        ExcelUtil<WmsInboundType> util = new ExcelUtil<WmsInboundType>(WmsInboundType.class);
        util.exportExcel(response, list, "入库类型数据");
    }

    /**
     * 获取入库类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:inboundType:query')")
    @GetMapping(value = "/{orderType}")
    public AjaxResult getInfo(@PathVariable("orderType") String orderType)
    {
        return success(wmsInboundTypeService.selectWmsInboundTypeByOrderType(orderType));
    }

    /**
     * 新增入库类型
     */
    @PreAuthorize("@ss.hasPermi('system:inboundType:add')")
    @Log(title = "入库类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsInboundType wmsInboundType)
    {
        return toAjax(wmsInboundTypeService.insertWmsInboundType(wmsInboundType));
    }

    /**
     * 修改入库类型
     */
    @PreAuthorize("@ss.hasPermi('system:inboundType:edit')")
    @Log(title = "入库类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsInboundType wmsInboundType)
    {
        return toAjax(wmsInboundTypeService.updateWmsInboundType(wmsInboundType));
    }

    /**
     * 删除入库类型
     */
    @PreAuthorize("@ss.hasPermi('system:inboundType:remove')")
    @Log(title = "入库类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderTypes}")
    public AjaxResult remove(@PathVariable String[] orderTypes)
    {
        return toAjax(wmsInboundTypeService.deleteWmsInboundTypeByOrderTypes(orderTypes));
    }
}
